<?php

namespace framework;
class Container implements  \ArrayAccess
{
    public  $_single;
    public  $_instance;

    public function offsetGet($key) {
        if(!array_key_exists($key,$this->_instance)) {
            throw  new  \Exception("unkown $key");
        }
        return $this->_instance[$key];
    }

    public function offsetSet($key,$value) {
        if(isset($this->_instance[$key])) {
            return $this->_instance[$key];
        }
        $this->_instance[$key] = $value;
        return ;
    }


    public function __get($key) {
        if(!array_key_exists($key,$this->_instance)) {
            throw  new  \Exception("unkown $key");
        }
        return $this->_instance[$key];
    }

    public function __set($key,$value) {
        if(isset($this->_instance[$key])) {
            return $this->_instance[$key];
        }
        $this->_instance[$key] = $value;
        return ;
    }

    public function offsetUnset($key) {

    }

    public function offsetExists($key) {

    }
}